package com.xiaobu.shop.controller;


import com.xiaobu.shop.domain.ResponseResult;
import com.xiaobu.shop.domain.entity.ShopProduct;
import com.xiaobu.shop.domain.query.QueryProductParameter;
import com.xiaobu.shop.service.ShopProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 * * @author xiaobu
 * @since 20230616
 */
@RestController
@RequestMapping("/shop/product")
public class ShopProductController {


    @Autowired
    private ShopProductService shopProductService;


    /**
     * 产品分页
     * @param
     * @return
     */
    @RequestMapping("/productPage")
    public ResponseResult productPage(@RequestBody QueryProductParameter queryProductParameter){
        ResponseResult productPage = (ResponseResult) shopProductService.getProductPage(queryProductParameter);
        return productPage;
    }

    @RequestMapping("/detail/{id}")
    public ResponseResult productPage(@PathVariable("id")Long id){
        ShopProduct product = shopProductService.getById(id);
        ResponseResult responseResult=new ResponseResult(200,"获取成功",product);
        return responseResult;
    }
}

